package com.haha;

import java.nio.ByteBuffer;

import static com.haha.ByteBufferUtil.debugAll;

public class TestByteBufferRead {
    public static void main(String[] args) {
        ByteBuffer buffer = ByteBuffer.allocate(10);
        buffer.put(new byte[]{'a','b','c','d'});
        buffer.flip();
//        buffer.get(new byte[4]);
//        debugAll(buffer);
//        buffer.rewind();
//        buffer.get();
//        debugAll(buffer);
//        System.out.println((char) buffer.get());
//        System.out.println((char) buffer.get());
//        System.out.println((char) buffer.get());
//        buffer.mark();//加标记，索引2的位置
//        System.out.println((char) buffer.get());
//        System.out.println((char) buffer.get());
//        buffer.reset();//将position重置到索引2的位置
//        System.out.println((char) buffer.get());
//        System.out.println((char) buffer.get());
        System.out.println((char) buffer.get(3));
        debugAll(buffer);
    }
}
